﻿#include "addremovefileswidget.h"
#include <QScreen>
addRemoveFilesWidget::addRemoveFilesWidget(QWidget *parent) :
    QWidget(parent)
{
    this->setWindowTitle(tr("增加删除项目文件"));
    this->setObjectName("addRemoveFilesWidget");
    this->setWindowModality(Qt::ApplicationModal);
    this->manualCreateUI();
    this->resize(QGuiApplication::primaryScreen()->geometry().width()/10*7,this->minimumHeight());
}

void addRemoveFilesWidget::manualCreateUI()
{
    /*文件浏览及相关按钮*/
    treeView = new QTreeView();
    listView = new QListView();

    QSplitter *middle_left_splite = new QSplitter(Qt::Horizontal);
    middle_left_splite->addWidget(treeView);
    middle_left_splite->addWidget(listView);
    middle_left_splite->setStretchFactor(0,1);
    middle_left_splite->setStretchFactor(1,1);

    QPushButton *add        = new QPushButton(tr("添加"));
    QPushButton *addAll     = new QPushButton(tr("全部添加"));
    QPushButton *addTree    = new QPushButton(tr("添加树"));
    QPushButton *removeTree = new QPushButton(tr("移除树"));

    QVBoxLayout *middle_rigth_layout = new QVBoxLayout();
    middle_rigth_layout->addStretch(2);
    middle_rigth_layout->addWidget(add);
    middle_rigth_layout->addStretch(1);
    middle_rigth_layout->addWidget(addAll);
    middle_rigth_layout->addStretch(1);
    middle_rigth_layout->addWidget(addTree);
    middle_rigth_layout->addStretch(1);
    middle_rigth_layout->addWidget(removeTree);
    middle_rigth_layout->addStretch(2);

    QHBoxLayout *middle_layout = new QHBoxLayout();
    middle_layout->addWidget(middle_left_splite,1);
    middle_layout->addLayout(middle_rigth_layout);
    middle_layout->setContentsMargins(0,0,0,0);

    QWidget *middle_widget = new QWidget();
    middle_widget->setLayout(middle_layout);

    QPushButton *remove     = new QPushButton(tr("移除"));
    QPushButton *removeAll  = new QPushButton(tr("全部移除"));
    QPushButton *addFromList= new QPushButton(tr("添加列表"));

    QVBoxLayout *bottom_rigth_layout = new QVBoxLayout();
    bottom_rigth_layout->addStretch(2);
    bottom_rigth_layout->addWidget(remove);
    bottom_rigth_layout->addStretch(1);
    bottom_rigth_layout->addWidget(removeAll);
    bottom_rigth_layout->addStretch(1);
    bottom_rigth_layout->addWidget(addFromList);
    bottom_rigth_layout->addStretch(2);

    fileView = new QListView();

    QHBoxLayout *bottom_layout = new QHBoxLayout();
    bottom_layout->addWidget(fileView,1);
    bottom_layout->addLayout(bottom_rigth_layout);
    bottom_layout->setContentsMargins(0,0,0,0);

    QWidget *bottom_widget = new QWidget();
    bottom_widget->setLayout(bottom_layout);

    QSplitter *up_down = new QSplitter(Qt::Vertical);
    up_down->addWidget(middle_widget);
    up_down->addWidget(bottom_widget);
    up_down->setStretchFactor(0,1);
    up_down->setStretchFactor(1,1);

    QVBoxLayout *main_layout = new QVBoxLayout();
    main_layout->addWidget(up_down);
    setLayout(main_layout);
}
